javascript does key exist

66

javascript hashtable contains key -

if (obj.hasOwnProperty("key1")) {
  ...
}

js check if object key exists -

var obj = { key: undefined };
obj["key"] !== undefined // false, but the key exists!

Comments

Submit
0 Comments